using System;
using System.Threading.Tasks;
using JlPay.Sdk.Core;
using JlPay.Sdk.Models.Openmerch.Device;

namespace JlPay.Sdk.Services.Openmerch.Device
{
    /// <summary>
    /// 设备管理服务类
    /// @author liaochangyi
    /// @since 2025-01-25
    /// </summary>
    public class DeviceService : BaseService
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="config">配置对象</param>
        public DeviceService(Config config) : base(config)
        {
        }

        /// <summary>
        /// 终端查询
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<DeviceQueryResponse> DeviceQueryAsync(DeviceQueryRequest request)
        {
            return await PostAsync<DeviceQueryRequest, DeviceQueryResponse>(request, DeviceQueryRequest.API_URL);
        }

        /// <summary>
        /// 查询银联码
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<UnionPayCodeQueryResponse> QueryUnionpayCodeAsync(UnionPayCodeQueryRequest request)
        {
            return await PostAsync<UnionPayCodeQueryRequest, UnionPayCodeQueryResponse>(request, UnionPayCodeQueryRequest.API_URL);
        }

        /// <summary>
        /// 添加银联码
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<UnionPayCodeAddResponse> AddUnionpayCodeAsync(UnionPayCodeAddRequest request)
        {
            return await PostAsync<UnionPayCodeAddRequest, UnionPayCodeAddResponse>(request, UnionPayCodeAddRequest.API_URL);
        }

        /// <summary>
        /// 变更设备
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<DeviceChangeResponse> ChangeDeviceAsync(DeviceChangeRequest request)
        {
            return await PostAsync<DeviceChangeRequest, DeviceChangeResponse>(request, DeviceChangeRequest.API_URL);
        }

        /// <summary>
        /// 撤销设备
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<DeviceCancelResponse> CancelDeviceAsync(DeviceCancelRequest request)
        {
            return await PostAsync<DeviceCancelRequest, DeviceCancelResponse>(request, DeviceCancelRequest.API_URL);
        }

        /// <summary>
        /// 添加设备
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>响应对象</returns>
        public async Task<DeviceAddResponse> AddDeviceAsync(DeviceAddRequest request)
        {
            return await PostAsync<DeviceAddRequest, DeviceAddResponse>(request, DeviceAddRequest.API_URL);
        }
    }
} 